package com.hjt.tools.generation;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public abstract class IGenerationConstant {
	public final String PROJECT_PATH = new File("").getAbsolutePath();
	public final String SRC_PATH = PROJECT_PATH + "\\src";
	public final String TEMPLATE_PATH = SRC_PATH  + "\\com\\hjt\\tools\\generation\\template";
	
	public List<String> templateContentList = new ArrayList<String>();	//模板文件内容，已行为单位
	public List<Integer> flagList = new ArrayList<Integer>();	//标志模板文件中存在替换符号的行数
	public Map<String, String>flagMap = new HashMap<String, String>();	//标志替换模板的值
	
	public void replaceFlag(){
		for(int i=0,len=flagList.size(); i<len; i++){
			replaceLine(flagList.get(i));
		}
	}
	
	private final void replaceLine(int lineNum){
		//System.out.println(templateContentList.get(lineNum));
		for (Map.Entry<String, String> entry : flagMap.entrySet()) {  
		    //System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());  
			String content = templateContentList.get(lineNum);
		    if(content.contains(entry.getKey())){
		    	content = content.replace(entry.getKey(), entry.getValue());
		    	templateContentList.set(lineNum, content);
		    }
		}
		//System.out.println(templateContentList.get(lineNum));
	}
	
}
